<?php
require ('../ht/Common/db.php');
//连接数据库
$bid=$_POST["bid"];
session_start();
//根据user的session值取得uid
if(isset($_SESSION["user"]))
{
    $uname=$_SESSION["user"];
    $sql1="select uid from users where uname='$uname'";
    $rs1=mysql_query($sql1)or die('查询1失败！'.mysql_error());
    $row1=mysql_fetch_assoc($rs1);
    $uid=$row1["uid"];
    echo "uid=".$uid;
}
$content=$_POST["content"];
$sql2="insert into comments values(0,'$content',NOW(),$uid,$bid)";
echo $sql2;
$rs2=mysql_query($sql2)or die('查询2失败！'.mysql_error());
if($rs2>0){
    header("location:show.php?bid=$bid");
}
else{
    echo "本次留言失败两秒后返回当前页~";
    header("refresh:2;url='show.php?bid=$bid'");
}
?>
<?php
